<template>
    <div id="OrdersTitle">
        <v-details :inputConfig="inputConfig" :detailData="inputData" :rules="rules" @pop="setdata"
                   ref="input"></v-details>
    </div>
</template>

<script>
    import details from 'commons/Detail'
    import baseMixin from "@/mixins/BaseMixin";

    export default {
        props: {
            inputData: {
                type: Object,
            }
        },
        mixins: [baseMixin],
        name: "OrdersTitle",
        data() {
            return {
                newFlag: false,
            }
        },
        computed: {
            inputConfig() {
                return [
                    [
                        {
                            type: "input",
                            label: this.$t('work.transferkey'),
                            props: "transferkey",
                            disabled: true
                        },
                        {
                            type: "input",
                            label: this.$t('work.fromstorerkey'),
                            props: "fromstorerkey",
                            disabled: true
                        },
                        {
                            type: "table",
                            label: this.$t('work.frtxshipstore'),
                            props: "frtxshipstore",
                            tableConfig: [
                                {
                                    label: this.$t('common.code'),
                                    prop: "code",
                                    input: "input",
                                },
                                {
                                    label: this.$t('common.desc'),
                                    prop: "description",
                                    input: "input",
                                }
                            ],
                            url: `/queryshipstore/${this.inputData.fshippers}/?/${this.$store.state.wms}`
                        }
                    ],
                    [
                        {
                            type: "input",
                            label: this.$t('in.externreceiptkey2'),
                            props: "externtransferkey",
                            disabled: true
                        },
                        {
                            type: "input",
                            label: this.$t('work.tostorerkey'),
                            props: "tostorerkey",
                            disabled: true
                        },
                        {
                            type: "table",
                            label: this.$t('work.trtxshipstore'),
                            props: "trtxshipstore",
                            tableConfig: [
                                {
                                    label: this.$t('common.code'),
                                    prop: "code",
                                    input: "input",
                                },
                                {
                                    label: this.$t('common.desc'),
                                    prop: "description",
                                    input: "input",
                                }
                            ],
                            url: `/queryshipstore/${this.inputData.fshippers}/?/${this.$store.state.wms}`
                        }
                    ],
                    [
                        {
                            type: "select",
                            label: this.$t('work.addstatus'),
                            props: "status",
                            options: this.getOptions("codelkup/RTXTRANSFERSTA"),
                            disabled: true
                        },
                        {
                            type: "select",
                            label: this.$t('work.apistatus'),
                            props: "transferfinishflag",
                            options: [
                                {code: 'P', description: 'P'},
                                {code: 'S', description: 'S'},
                                {code: 'PS', description: 'PS'},
                                {code: 'PF', description: 'PF'}
                            ]
                        },
                        {
                            type: "input",
                            label: this.$t('work.apiinfo'),
                            props: "msg",
                            disabled: true
                        }
                    ]
                ]

            },
            rules() {
                return {
                    transferkey: [
                        {required: true, trigger: 'blur'},
                    ],
                    fromstorerkey: [
                        {required: true, trigger: 'blur'},
                    ],
                    frtxshipstore: [
                        {required: true, trigger: 'blur'},
                    ],
                    externtransferkey: [
                        {required: true, trigger: 'blur'},
                    ],
                    tostorerkey: [
                        {required: true, trigger: 'blur'},
                    ],
                    trtxshipstore: [
                        {required: true, trigger: 'blur'},
                    ],
                    status: [
                        {required: true, trigger: 'blur'},
                    ],
                    transferfinishflag: [
                        {required: true, trigger: 'blur'},
                    ],
                    msg: [
                        {required: true, trigger: 'blur'},
                    ]
                }
            }
        },
        methods: {
            setdata(data, id, close, listId) {
                if (listId == "0") {
                    this.inputData.frtxshipstore = data.code;
                } else if (listId == "1") {
                    this.inputData.trtxshipstore = data.code;
                }
                close(false);
            }
        },
        mounted() {
            if (Object.keys(this.$store.state.skip).length !== 0) {
                let data = this.$store.state.skip;
                this.newFlag = data.newFlag;
            } else {
                this.newFlag = this.$store.state.newFlag;
            }
        },
        watch: {},
        components: {
            'v-details': details
        }
    }
</script>

<style scoped>

</style>
